package com.su.producer.service.Impl;

import com.su.producer.service.DirectService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class DirectServiceImpl implements DirectService {



    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Override
    public void sendMessage(String message,String routingKey) {

        System.out.println(message);

rabbitTemplate.convertAndSend("direct-exchange",routingKey,message);


    }

    @Override
    public void confirm(CorrelationData correlationData, boolean b, String s) {


        if (b) {
           log.info("confirm回调方法>>>>>>>>>>>>>消息发送成功");
        } else {
            log.info("confirm回调方法>>>>>>>>>>>>>消息发送失败" + s);
        }

    }
}
